//
//  AXMySrdzWdktVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/7.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXMySrdzWdktVC.h"
#import "XXPageTabView.h"
#import "XXPageTabItemLable.h"
#import "Header.h"
#import "ZXCategories.h"
#import "AXMySrdzWdktYgmVC.h"
#import "AXMySrdzWdktZjygVC.h"
#import "AXMySrdzWdktDkygVC.h"
#import "AXMySrdzWdktScVC.h"
#import "UIViewController+HBD.h"


@interface AXMySrdzWdktVC ()<XXPageTabViewDelegate>

@property (nonatomic, strong) XXPageTabView *pageTabView;

@end

@implementation AXMySrdzWdktVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.pageTabView];
    [self setupNavigationItems];
    self.hbd_barTintColor = [UIColor whiteColor];
    self.hbd_barShadowHidden = YES;

    
}

- (void)setupNavigationItems {
    
    /** 导航条左边的按钮 */
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 30, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel.textColor = [UIColor colorWithHex:0x29b566];
    titleLabel.text = @"我的课堂";
    self.navigationItem.titleView = titleLabel;
    
    
    
}

#pragma mark - Action

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)search:(UIButton *)btn {
    
}


- (XXPageTabView *)pageTabView
{
    if (!_pageTabView) {
        
        AXMySrdzWdktYgmVC *vc1 = [[AXMySrdzWdktYgmVC  alloc] init];
        [self addChildViewController:vc1];
        
        AXMySrdzWdktZjygVC *vc2 = [[AXMySrdzWdktZjygVC alloc] init];
        [self addChildViewController:vc2];
        
        AXMySrdzWdktDkygVC *vc3 = [[AXMySrdzWdktDkygVC  alloc] init];
        [self addChildViewController:vc3];
        
        AXMySrdzWdktScVC *vc4 = [[AXMySrdzWdktScVC  alloc] init];
        [self addChildViewController:vc4];
        
        
        
        
        
        //支持网易云音乐，今日头条，微博等切换栏效果
        _pageTabView = [[XXPageTabView alloc] initWithChildControllers:self.childViewControllers childTitles:@[@"已购买", @"专家预告",@"大咖预告",@"收藏"]];
        _pageTabView.frame = CGRectMake(0, Hn, Wi, Hi-Hn);
        
        _pageTabView.selectedTabIndex = 0;
        _pageTabView.maxNumberOfPageItems = 5;
        _pageTabView.tabSize = CGSizeMake(Wi, 44);
        _pageTabView.tabItemFont = FONT_FOURTEEN;
        
        _pageTabView.unSelectedColor = White(50);
        _pageTabView.selectedColor = COLOR_GREEN;
        
        _pageTabView.tabBackgroundColor = [UIColor whiteColor];
        
//        _pageTabView.separatorColor = [[UIColor grayColor] colorWithAlphaComponent:0.4];
        _pageTabView.bodyBounces = NO;
        
        _pageTabView.indicatorWidth = 50;
        _pageTabView.indicatorHeight = 2;
        
        _pageTabView.delegate = self;
        _pageTabView.titleStyle = XXPageTabTitleStyleDefault;
        _pageTabView.indicatorStyle = XXPageTabIndicatorStyleDefault;
        
        UIScrollView *bodyView = [_pageTabView valueForKey:@"bodyView"];
        [bodyView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
    }
    return _pageTabView;
}

- (void)pageTabViewDidEndChange
{
    DLog(@"page = %i", (int)self.pageTabView.selectedTabIndex);
}





@end
